from keras.models import model_from_json


# save model
def saveModel(model, modelFilePath):
    with open(modelFilePath, 'w') as file:
        file.write(model.to_json())

# load model
def loadModel(modelFilePath):
    with open(modelFilePath, 'r') as file:
        return model_from_json(file.read())

# saved model dir
def getModelDir(modelName):
    return 'results/' + modelName

# saved model file path
def getModelFilePath(modelName):
    return 'results/' + modelName + '/' + modelName + '.json'

# saved model weights file path
def getModelWeightsFilePath(modelName):
    return 'results/' + modelName + '/' + modelName + '.h5'

# saved model train loss file path
def getModelTrainLossFilePath(modelName):
    return 'results/' + modelName + '/' + modelName + '_train_loss'

# saved model train loss progress file path
def getModelTrainLossProgressFilePath(modelName):
    return 'results/' + modelName + '/' + modelName + '_train_loss_progress'

# saved model test loss file path
def getModelTestLossFilePath(modelName):
    return 'results/' + modelName + '/' + modelName + '_test_loss'







def baseN(num,b):
    return ((num == 0) and  "0" ) or ( baseN(num // b, b).lstrip("0") + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[num % b])